<CFQUERY NAME="getclient" DATASOURCE="#dsn#">
select *
from tblcustomers
where CustomerNum = <cfqueryparam cfsqltype="cf_sql_integer" value="#accountnumber#">

</CFQUERY>

<cfif isdefined("url.ReceiptNum")>
<CFQUERY NAME="getorders" DATASOURCE="#dsn#">
select *
from tblorders
where ReceiptNum = #ReceiptNum#
</CFQUERY>

<CFQUERY NAME="gettype" DATASOURCE="#dsn#">
select *
from tblpayments
where ReceiptNum = #ReceiptNum#
</CFQUERY>

<CFQUERY NAME="getitems" DATASOURCE="#dsn#">
select *
from tbltransactions, tblproducts
where ReceiptNum = #ReceiptNum# and tbltransactions.ProdID = tblproducts.ProdID
</CFQUERY>

<CFQUERY NAME="getitemssum" DATASOURCE="#dsn#">
select sum(Price) as total, sum(TaxAmount) as totaltax
from tbltransactions
where ReceiptNum = #ReceiptNum#
</CFQUERY>

<CFIF #getitemssum.total# LTE 0>
<CFSET getitemssum.total = 0>
</CFIF>

<CFIF #getitemssum.totaltax# LTE 0>
<CFSET getitemssum.totaltax = 0>
</CFIF>


<CFSET TOTAMOUNT = #getitemssum.total# + #getitemssum.totaltax#>

</cfif>

<style type="text/css">
<!--
body {
	font: 100% Verdana, Arial, Helvetica, sans-serif;
	background: #FFF;
	margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
	padding: 0;
	text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
	color: #000000;
}
.oneColFixCtr #container {
	width: 250px;  /* using 20px less than a full 800px width allows for browser chrome and avoids a horizontal scroll bar */
	background: #FFFFFF; /* the auto margins (in conjunction with a width) center the page */
	border: 0px solid #000000;
	text-align: left; /* this overrides the text-align: center on the body element. */
	margin-top: 0;
	margin-right: 0;
	margin-bottom: 0;
	margin-left: 0;
}
.oneColFixCtr #mainContent {
	padding: 0 0 px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
}
.style1 {
	font-size: 18px
}
.style4 {font-size: 10px}
.style9 {font-size: 10}
.style10 {font-size: 16px}
.style12 {font-size: 10; font-weight: bold; }
-->
</style>
<style>
.break { page-break-before: always; }
</style>
</head>

<body class="oneColFixCtr" onload="window.print(); window.close();">

<div id="container">
  <div id="mainContent">
<cfloop from="1" to="2" index="this_count">
   <cfoutput> <h1 align="center" class="style1">#getclient.CompanyName#<br />
      <span class="style4">#getclient.Address#<br />
      #getclient.City#, #getclient.State# #getclient.Zip#<br />
    Phone #getclient.Phone#
	<cfif Len(trim(getclient.Website)) GT 1>
    <br />#getclient.Website#
	</cfif>
	</span></h1></cfoutput>
    <DIV class="COL ONE style4">
      <p align="center"><strong><span class="style10">SALE</span><br />
      </strong></p>
    </DIV>
    <DIV class="COL TWO"><table width="100%" border="0" cellspacing="1" cellpadding="1">
  <cfoutput query="getitems"><tr>
    <td width="46%" class="style4"><span class="style9">#ProductName#</span></td>
    <td width="54%" align="right" class="style4"><span class="style9">#lscurrencyformat(Price)#</span></td>
  </tr></cfoutput>
  <tr>
    <td colspan="2" align="right" class="style4"><hr /></td>
    </tr>
  <tr>
    <td align="right" class="style4">Sub Total</td>
    <td align="right" class="style4"><cfoutput>#lscurrencyformat(getitemssum.total)#</cfoutput></td>
  </tr>
  <tr>
    <td align="right" class="style4"><span class="style9">Tax:</span></td>
    <td align="right" class="style4"><span class="style9"><cfoutput>#lscurrencyformat(getitemssum.totaltax)#</cfoutput></span></td>
  </tr>
  <tr>
    <td colspan="2" align="left" class="style4"><hr /></td>
    </tr>
  <tr>
    <td align="right" class="style4"><span class="style9">Total:</span></td>
    <td align="right" class="style4"><span class="style12"><cfoutput>#lscurrencyformat(TOTAMOUNT)#</cfoutput></span></td>
  </tr>
</table>
</DIV>
  <cfoutput>  <p class="style4">Payment Type: #gettype.PaymentType#</p>
<p class="style4">
<cfif gettype.PaymentType Contains "Credit">
#getorders.FirstName# #getorders.LastName#<br />
      Card: XXXX-XXXX-XXXX-#getorders.LastFour#<br />
      TID: #getorders.CartID#<br />
</cfif>
       Order Number: #getorders.ReceiptNum#<br />
      Terminal ID: #getorders.Terminal#<br />
    Date: #dateformat(getorders.TransDate, "mm/dd/yyyy")# #getorders.TransTime#</p>
    <p class="style4">&nbsp;</p>
		<cfif this_count is 2>
    <p align="center" class="style4">Please keep receipt as proof of purchase<br />
	</cfif>
    Thank you for your business</p>
	<cfif this_count is 1>
    <p align="center" class="style4">&nbsp;</p>
    <p align="center" class="style4">x________________________________________</p>
    <p align="center" class="style4">Merchant Copy</p>
    <p class="style4"><br /></p>
	<p class="break">
	</p>
	</cfif>
		</cfoutput>
</cfloop>
  <!-- end #mainContent --></div>
<!-- end #container --></div>
<p class="break">